﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using WebApplication6.Models;

namespace WebApplication6.Controllers
{
    public class DefaultController : Controller
    {
        Model1 model = new Model1();
        // GET: Default
        public ActionResult Index()
        {
            var list = model.Students.ToList();
            return View(list);
        }
        public ActionResult Create() {
            return View();
        }
        [HttpPost]
        public ActionResult Create(Student student) 
        {
            if (ModelState.IsValid) { 
            model.Students.Add(student);
            var result = model.SaveChanges();
            if (result>0) {
                return RedirectToAction("Index");
            
            }
            }
            return View(student);
        }
    }
}